package com.petshop.webSocketServer;

import com.petshop.config.GetHttpSessionConfig;
import jakarta.servlet.http.HttpSession;
import jakarta.websocket.*;
import jakarta.websocket.server.ServerEndpoint;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
@ServerEndpoint(value = "/webSocket", configurator = GetHttpSessionConfig.class)
public class WebSocketServer {

    //创建一个共享的集合常量，用来存储在线的用户的会话信息
    private static final Map<String, Session> onlineUsers = new ConcurrentHashMap<String, Session>();
    private HttpSession httpSession;

    @OnOpen
    public void onOpen(EndpointConfig config) {

    }

    @OnMessage
    public void onMessage(Session session, String message) throws IOException {
    }

    @OnClose
    public void onClose(Session session) {
    }
}
